package com.netty.example.time.pojosolusion;

import com.netty.example.time.UnixTime;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * 简化的 {@link PojoTimeEncoder}
 */
public class SimplePojoTimeEncoder extends MessageToByteEncoder<UnixTime> {


    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, UnixTime msg, ByteBuf out) throws Exception {
        out.writeInt((int) msg.value());

    }
}
